package test2.experiment5;

import java.util.Scanner;

public class Practice5_1 {
    public static void main(String[] args) {
        int a = 0, b = 0;
        Practice5_1 hh = new Practice5_1();
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        System.out.println("a = " + a);
        System.out.println("b = " + b);
        int q = hh.myDivide(a, b);
        System.out.println("q = " + q);
        try {
            q = hh.myMode(a, b);
        } catch (ArithmeticException e) {
            System.out.println("求余运算异常：" + "除数为0");
        }
        sc.close();
    }

    int myDivide(int a, int b) {
        int q = 0;
        try {
            q = a / b;
        } catch (ArithmeticException e) {
            System.out.println("整除运算异常：" + "除数为0");
        }
        return q;
    }

    int myMode(int a, int b) {
        int q = 0;
        q = a % b;
        System.out.println(a + " % " + b + " = " + q);
        return  q;
    }
}
